package leetcode.weekly.week323;

import java.util.Arrays;

//Solution1Test
public class Solution1 {

	public int deleteGreatestValue(int[][] grid) {
		for (int i = 0; i < grid.length; i++) {
			Arrays.sort(grid[i]);
		}
		int ans = 0;
		int m = grid.length, n = grid[0].length;
		for (int i = 0; i < n; i++) {
			int cur = Integer.MIN_VALUE;
			for (int j = 0; j < m; j++) {
				int num = grid[j][i];
				cur = Math.max(cur, num);
			}
			ans += cur;
		}
		return ans;
	}
}
